class CommonUtils {
  static getMaxValuesLength(arrays) {
    let maxLength = 0;
    arrays.forEach(value =>{
      maxLength = maxLength < value.length ? value.length : maxLength;
    });
    return maxLength;
  }
  static generateContactText(sourceId, targetId) {
    const sourceElement = document.getElementById(sourceId);
    const targetElement = document.getElementById(targetId);
    let sourceText = (sourceElement.children[0].children[0] === undefined)
      ? sourceElement.children[0].innerText : sourceElement.children[0].children[0].value;
    let targetText = (targetElement.children[0].children[0] === undefined)
      ? targetElement.children[0].innerText : targetElement.children[0].children[0].value;
    sourceText = this.removeSpecialSimbol(sourceText);
    targetText = this.removeSpecialSimbol(targetText);
    return sourceText === targetText ? sourceText : `${sourceText}_${targetText}`;
  }
  static removeSpecialSimbol(text) {
    return text.replace('├─', '').replace('└─', '');
  }
  static generateContactId(sourceId, targetId) {
    return `${sourceId}|${targetId}`;
  }

  static generateAnalyzeData(datas) {
    const analyzeData = [];
    if (datas && datas.length) {
      const keys = [];
      const values = [];
      datas.forEach(item=>{
        keys.push(item.tableAttribute.labelName);
        values.push(item.elementDataList);
      });
      analyzeData.push(keys);
      const maxLength = this.getMaxValuesLength(values);
      for (let index = 0; index < maxLength; index++) {
        const analyDataItem = [];
        values.forEach(value =>{
          analyDataItem.push(value[index] === undefined ? '' : value[index]);
        });
        analyzeData.push(analyDataItem);
      }
    }
    return analyzeData;
  }
}
export {
  CommonUtils

};